{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8ced8243-d770-437e-a90d-f794ffa57fc0",
   "metadata": {},
   "source": [
    "# Dataframe Plots"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1cf56fd3-605c-4449-8a5e-d0fd94b49080",
   "metadata": {},
   "outputs": [],
   "source": [
    "from data_generation import generate_data\n",
    "\n",
    "sales_data = generate_data(50)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "913c18ed-373b-400e-ba27-38ca8e7b70b9",
   "metadata": {},
   "source": [
    "## polars Plotting"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "014e9e56-8fff-45ab-85ff-eb51840f2bc7",
   "metadata": {},
   "outputs": [],
   "source": [
    "import polars as pl\n",
    "\n",
    "orders_polars = pl.DataFrame(sales_data)\n",
    "\n",
    "(\n",
    "    orders_polars.group_by(\"region\")\n",
    "    .agg(total_sales=pl.col(\"sales_income\").sum())\n",
    "    .plot.bar(x=\"region\", y=\"total_sales\")\n",
    "    .properties(width=200, height=200, title=\"Total Sales per Region ($)\")\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a62335eb-4763-4c46-adb2-d7386914f56b",
   "metadata": {},
   "source": [
    "## Pandas Plotting"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "85929590-e514-4497-b396-58cfe26e59d3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "orders_pandas = pd.DataFrame(sales_data)\n",
    "\n",
    "(\n",
    "    orders_pandas.groupby(\n",
    "        [\n",
    "            \"region\",\n",
    "        ]\n",
    "    )[\"sales_income\"]\n",
    "    .sum()\n",
    "    .plot(kind=\"bar\", title=\"Total Sales per Region ($)\", ylabel=\"total_sales\")\n",
    ")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
